home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / ps40sdk / examples / format / simpleformat / simpleformatuiwin.c < prev   
Encoding:
C/C++ Source or Header  |  1996-08-28  |  3.6 KB  |  146 lines

  1. /*
  2.     File: SimpleFormatUIWin.c
  3.  
  4.     Copyright 1993-6, Adobe Systems Incorporated.
  5.     All rights reserved.
  6.  
  7.     C source file for MS-Windows specific code for SimpleFormat Plug-In
  8. */
  9.  
  10. #include "SimpleFormat.h"
  11. #include "WinDialogUtils.h"
  12.  
  13. /*
  14. #include "PITypes.h"
  15. #include "PIgeneral.h"
  16. #include "PIAbout.h"
  17. #include "FormatUtilities.h"
  18.  
  19. #include <windows.h>
  20.  
  21. #include <stdlib.h>
  22. #include "errno.h"
  23. #include "string.h"
  24.  
  25. #include "WinUtil.h"
  26. */
  27.  
  28. /*****************************************************************************/
  29.  
  30. //BOOL WINAPI FormatProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
  31.  
  32. /*****************************************************************************/
  33.  
  34. void DoAbout (GPtr globals)
  35. {
  36.     ShowAbout((AboutRecordPtr)gStuff, hDllInstance, AboutID);
  37. }
  38.  
  39. /*****************************************************************************/
  40.  
  41. /* File I/O Routines. */
  42.  
  43. OSErr FSWrite(int32 refNum, long *count,void *buffPtr)
  44. {
  45.     /* Note:  this routine doesn't work for data larger than 64k. */
  46.  
  47.     WORD bytes;
  48.  
  49.     bytes = (WORD)*count;
  50.     if ((*count = _lwrite((int)refNum,(LPSTR)buffPtr,bytes))==0xffff)
  51.         return writErr;
  52.  
  53.     return noErr;
  54. }
  55.  
  56.  
  57. OSErr SetFPos (int32 refNum, short posMode, long posOff)
  58. {
  59.     _llseek((int)refNum, posOff, posMode);
  60.     return noErr;    // just for samples sake. should return error value based on __llseek's
  61. }
  62.  
  63. OSErr FSRead(int32 refNum, long *count    , void *buffPtr)
  64. {
  65.     WORD bytes;
  66.  
  67.     bytes = (WORD) *count;
  68.  
  69.     if ((*count = _lread((int)refNum,(LPSTR)buffPtr,bytes))==0xffff)
  70.         return readErr;
  71.  
  72.     return noErr;
  73. }
  74.  
  75. /****************************************************************************/
  76. /* Example for ShowAlert() function which takes a string ID as parameter    */
  77. /* and displays a message box                                               */
  78. /****************************************************************************/
  79.  
  80. short ShowAlert (short stringID)
  81. {
  82.     char szMessage[256];
  83.     char szTitle[128];
  84.  
  85.     LoadString(hDllInstance, stringID, szMessage, sizeof szMessage);
  86.     LoadString(hDllInstance, 2, szTitle, sizeof szTitle);
  87.     return  ( MessageBox(NULL, szMessage, szTitle, MB_OK | MB_ICONHAND) );
  88.  
  89. }
  90.  
  91.  
  92. /* Initialization and termination code for window's dlls. */
  93.  
  94. // Win32 Change
  95. #ifdef WIN32
  96.  
  97. // Every 32-Bit DLL has an entry point DLLInit
  98.  
  99. BOOL APIENTRY DLLInit(HANDLE hInstance, DWORD fdwReason, LPVOID lpReserved)
  100. {
  101.  
  102.     if (fdwReason == DLL_PROCESS_ATTACH)
  103.         hDllInstance = hInstance;
  104.  
  105.     return TRUE;   // Indicate that the DLL was initialized successfully.
  106. }
  107.  
  108. #else
  109. /* ------------------------------------------------
  110.  *   Code from Borland's window's dll example code.
  111.  * ------------------------------------------------
  112.  */
  113. #if defined(__BORLANDC__)
  114. // Turn off warning: Parameter '' is never used; effects next function only
  115. #pragma argsused
  116. #endif
  117.  
  118. // Every DLL has an entry point LibMain and an exit point WEP.
  119. int FAR PASCAL LibMain( HANDLE hInstance, WORD wDataSegment,
  120.                                    WORD wHeapSize, LPSTR lpszCmdLine )
  121. {
  122.     // Required when using Zortech; causes blink to include startup code
  123.     extern __acrtused_dll;
  124.  
  125.     // The startup code for the DLL initializes the local heap (if there is one)
  126.     // with a call to LocalInit which locks the data segment.
  127.     if ( wHeapSize != 0 )
  128.         UnlockData( 0 );
  129.  
  130.     hDllInstance = hInstance;
  131.     return 1;   // Indicate that the DLL was initialized successfully.
  132. }
  133.  
  134. int FAR PASCAL WEP(int nParam)
  135. {
  136.     switch  (nParam) {
  137.       case  WEP_SYSTEM_EXIT: // System shutdown in progress
  138.       case  WEP_FREE_DLL   : // DLL use count is 0
  139.       default :              // Undefined;  ignore
  140.             return  1;
  141.     }
  142. }
  143. #endif
  144.  
  145.  
  146.